﻿using OnlineOrder.Entity;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace OnlineOrder.UI.用户窗体
{
    public partial class Dishes : Form
    {
        public Dishes()
        {
            InitializeComponent();
        }

        private void pictureBox1_Click(object sender, EventArgs e)
        {
            MessageBox.Show("火腿+米饭+肉片+配菜");
        }

        private void pictureBox2_Click(object sender, EventArgs e)
        {
            MessageBox.Show("鸭血+米饭+肉片+配菜");
        }

        private void pictureBox3_Click(object sender, EventArgs e)
        {
            MessageBox.Show("牛蛙+米饭+配菜");
        }

        private void pictureBox5_Click(object sender, EventArgs e)
        {
            MessageBox.Show("牛肉（素）+米饭+配菜");
        }

        private void pictureBox4_Click(object sender, EventArgs e)
        {
            MessageBox.Show("烤鸭+米饭+配菜");
        }

        private void pictureBox6_Click(object sender, EventArgs e)
        {
            MessageBox.Show("猪肉+鸡蛋+青红辣椒");
        }

        private void Dishes_Load(object sender, EventArgs e)
        {

        }

        private void add1_Click(object sender, EventArgs e)
        {
            string sql = $"select DishName,DishPrice from Dish where DishName='" + food1.Text + "'";
            DataTable dataTable1 = Utils.SqlHelper.ExecuteDataTable(sql);
            if (Middle.dataTable.Rows.Count > 0)
            {
                Middle.dataTable.Merge(dataTable1);
            }
            // 否则直接将查询得到的数据表赋值给 Middle.dataTable
            else
            {
                Middle.dataTable = dataTable1;
            }
            MessageBox.Show("添加成功");
        }

        private void add2_Click(object sender, EventArgs e)
        {
            string sql = $"select DishName,DishPrice from Dish where DishName='" + food2.Text + "'";
            DataTable dataTable2 = Utils.SqlHelper.ExecuteDataTable(sql);
            if (Middle.dataTable.Rows.Count > 0)
            {
                Middle.dataTable.Merge(dataTable2);
            }
            // 否则直接将查询得到的数据表赋值给 Middle.dataTable
            else
            {
                Middle.dataTable = dataTable2;
            }
            MessageBox.Show("添加成功");
        }

        private void add3_Click(object sender, EventArgs e)
        {
            string sql = $"select DishName,DishPrice from Dish where DishName='" + food3.Text + "'";
            DataTable dataTable3 = Utils.SqlHelper.ExecuteDataTable(sql);
            if (Middle.dataTable.Rows.Count > 0)
            {
                Middle.dataTable.Merge(dataTable3);
            }
            // 否则直接将查询得到的数据表赋值给 Middle.dataTable
            else
            {
                Middle.dataTable = dataTable3;
            }
            MessageBox.Show("添加成功");
        }

        private void add4_Click(object sender, EventArgs e)
        {
            string sql = $"select DishName,DishPrice from Dish where DishName='" + food4.Text + "'";
            DataTable dataTable4 = Utils.SqlHelper.ExecuteDataTable(sql);
            if (Middle.dataTable.Rows.Count > 0)
            {
                Middle.dataTable.Merge(dataTable4);
            }
            // 否则直接将查询得到的数据表赋值给 Middle.dataTable
            else
            {
                Middle.dataTable = dataTable4;
            }
            MessageBox.Show("添加成功");
        }

        private void add5_Click(object sender, EventArgs e)
        {
            string sql = $"select DishName,DishPrice from Dish where DishName='" + food5.Text + "'";
            DataTable dataTable5 = Utils.SqlHelper.ExecuteDataTable(sql);
            if (Middle.dataTable.Rows.Count > 0)
            {
                Middle.dataTable.Merge(dataTable5);
            }
            // 否则直接将查询得到的数据表赋值给 Middle.dataTable
            else
            {
                Middle.dataTable = dataTable5;
            }
            MessageBox.Show("添加成功");
        }

        private void add6_Click(object sender, EventArgs e)
        {
            string sql = $"select DishName,DishPrice from Dish where DishName='" + food6.Text + "'";
            DataTable dataTable6 = Utils.SqlHelper.ExecuteDataTable(sql);
            if (Middle.dataTable.Rows.Count > 0)
            {
                Middle.dataTable.Merge(dataTable6);
            }
            // 否则直接将查询得到的数据表赋值给 Middle.dataTable
            else
            {
                Middle.dataTable = dataTable6;
            }
            MessageBox.Show("添加成功");
        }
    }
}
